import {INCREMENT, DECREMENT, RESET} from '../actions/counter';

const initState = {
    count: 100,
    hello: 'hello me',
};

export default function reducer(state = initState, action) {
    // console.log('call reducer. state:'+JSON.stringify(state)+" action:"+JSON.stringify(action));
    switch (action.type) {
        case INCREMENT:
            return {
                count: state.count + 1,
                hello: state.hello,
            };
        case DECREMENT:
            return {
                count: state.count - 1,
                hello: state.hello,
            };
        case RESET:
            return {
                count: 0,
                hello: state.hello,
            };
        default:
            return state
    }
}